package com.yuntian.aspect;

import com.yuntian.annotation.Log;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class LogAspect {

    @Around("@annotation(log)")
    public Object around(ProceedingJoinPoint joinPoint, Log log) throws Throwable {
        // 方法执行前
        String methodName = joinPoint.getSignature().getName();
        System.out.println("开始执行: " + log.value() + " - " + methodName);

        // 执行方法
        Object result = joinPoint.proceed();

        // 方法执行后
        System.out.println("执行完成: " + log.value() + " - " + methodName);
        return result;
    }
}